import { fileURLToPath, URL } from 'node:url'

import { defineConfig, loadEnv } from "vite"
import vue from '@vitejs/plugin-vue'
import { viteMockServe } from "vite-plugin-mock"
import { createSvgIconsPlugin } from "vite-plugin-svg-icons"

// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
  // const env = loadEnv(mode, process.cwd()) as ImportMetaEnv;
  return {
    base: '/',
    plugins: [
      vue(),
      viteMockServe({
        enable: command === "serve"
      }),
      createSvgIconsPlugin({
        iconDirs: [fileURLToPath(new URL('./src/assets/svg', import.meta.url))],
        symbolId: 'icon-[name]',
      }),
    ],
    resolve: {
      alias: {
        '@': fileURLToPath(new URL('./src', import.meta.url))
      }
    },
    server: {
      proxy: {
      },
    },
  }
})
